package com.big.tree.aspect;

import com.big.tree.config.RoutingDataSourceContext;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;



/**
 * @author big tree
 */
@Aspect
@Component
public class RoutingWithAspect {

    @Around("@annotation(routingWith) || @within(routingWith)")
    public Object routingWithDataSource(ProceedingJoinPoint joinPoint, RoutingWith routingWith) throws Throwable {
        RoutingDataSourceContext routingDataSourceContext = new RoutingDataSourceContext(routingWith.value());
        return joinPoint.proceed();
    }
}
